package nio;// $Id$

import java.nio.ByteBuffer;

public class CreateArrayBuffer
{
  static public void main( String args[] ) throws Exception {
    byte array[] = new byte[1024];

    ByteBuffer buffer = ByteBuffer.wrap( array );

    buffer.put( (byte)'a' );
    buffer.put( (byte)'b' );
    buffer.put( (byte)'c' );
    System.out.println(buffer.position());
    System.out.println(buffer.limit());

    buffer.flip();

    System.out.println(buffer.position());
    System.out.println(buffer.limit());
    System.out.println(buffer.capacity());
    for (int i=0; i<buffer.limit(); i++) {
      System.out.println((char)buffer.get());
    }

//    System.out.println( (char)buffer.get() );
//    System.out.println( (char)buffer.get() );
//    System.out.println( (char)buffer.get() );
  }
}
